﻿#ifndef FINITEAQS_H
#define FINITEAQS_H

#include <QMainWindow>
#include "acqure.h"
#include "converter.h"
#include "qcustomplot.h"
#include <QThread>
#include <QTime>
#include <QTimer>
#include <QDateTime>
#include <QTableWidgetItem>
#include <QVector>
#include <QSharedPointer>

QT_BEGIN_NAMESPACE
namespace Ui { class FiniteAqs; }
QT_END_NAMESPACE

class FiniteAqs : public QMainWindow
{
    Q_OBJECT

public:
    FiniteAqs(QWidget *parent = nullptr, HANDLE dev_handle = INVALID_HANDLE_VALUE);
    ~FiniteAqs();
    void showEvent(QShowEvent *);
    QString get_datetime(bool flag);
    void log_update(const QString& msg);
    void data_update(const cv::Mat& mat);
    void map_update(const QPixmap& pixmap);
    void curve_update(const cv::Mat& mat);
    void plot_update();
signals:
    void call_testAqc();
    void call_loop_read();
private slots:
    void on_DataAqsBtn_clicked();

    void on_stopAqs_clicked();

    void on_setParameter_clicked();

    void on_DataClearBtn_clicked();

    void on_tabWidget_currentChanged(int index);

    void on_addPoint_clicked();

private:
    Ui::FiniteAqs *ui;
    HANDLE usb5630_h;
    Acqure* Dev5630;
    QThread* Acq_thread;
    Converter* converter;
    QThread* convert_thread;

    QCustomPlot* customPlot;
    QVector<cv::Point2d> lines;
    QVector<double> time_datas;
    QVector<double> lines_data0;
    QVector<double> lines_data1;
    QVector<double> lines_data2;
    QVector<double> lines_data3;
    QVector<double> lines_data4;
//    const int max_points_count = 8192;

    QTimer* plotTimer;

    int currentRow =0;
};
#endif // FINITEAQS_H
